<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>


    <title>商品新增</title>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/plugins/simditor/simditor.css" />
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/plugins/webuploader/webuploader.css"/>
    <link rel="stylesheet" type="text/css" href="css/demo/webuploader-demo.css"/>
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>
</head>

<body class="gray-bg">
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h1>修改楼层 <small></small></h1>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal" enctype="multipart/form-data">

                    <div class="form-group">

                        <br/>
                        <table id="table_s">
                            <tr>
                                <td style="width: 150px">分类名称：</td>
                                <td style="width: 500px">
                                    <input type="text" style="display: none" th:value="${wl_homefloor_style_pc_bean.id}" name="beanid"/>
                                    <select name="flname"  class="form-control" style="width: 300px;border-radius: 4%;">
                                        <option th:each="cate:${wl_category_parentName_Mapss}"  th:value="${cate.cateid}" th:text="${cate.catename}" th:if="${wl_homefloor_style_pc_bean.categoryid==cate.cateid}" selected="selected" ></option>
                                        <option th:each="cate:${wl_category_parentName_Mapss}"  th:value="${cate.cateid}" th:text="${cate.catename}" th:if="${wl_homefloor_style_pc_bean.categoryid!=cate.cateid}" ></option>
                                    </select>

                                </td>
                                <td style="width: 150px">楼层顺序：</td>
                                <td style="width: 500px">
                                    <input type="number" th:value="${wl_homefloor_style_pc_bean.homefloorstylesort}" name="lcsx"  class="form-control" style="width: 300px;border-radius: 4%;"/>
                                </td>
                            </tr>
                            <tr id="1">
                                <td style="width: 150px">新增商品分类：</td>
                                <td style="width: 500px">

                                    <select name="axb" id="d1" class="form-control" style="width: 300px;border-radius: 4%;">
                                        <option th:each="comm:${wl_commodity_getListss}" th:value="${comm.id}"  th:text="${comm.commodityname}"></option>
                                    </select>
                                </td>

                                <td style="width: 100px">
                                    <button type="button" class="btn btn-primary" id="mhcx">查询</button>
                                </td>

                                <td>
                                    <input type="text" id="mhname"  class="form-control" style="width: 300px;border-radius: 4%;"/>
                                </td>

                            </tr>

                            <tr>
                                <td style="width: 100px">删除商品分类：</td>
                                <td style="width: 500px">

                                    <select name="axbs" class="form-control" style="width: 300px;border-radius: 4%;">
                                        <option th:each="comm:${wl_commodity_getListss}" th:value="${comm.id}"  th:text="${comm.commodityname}"></option>
                                    </select>
                                </td>

                                <td style="width: 100px">
                                    <button type="button" class="btn btn-primary" id="mhcxs">查询</button>
                                </td>

                                <td>
                                    <input type="text" id="mhnames"  class="form-control" style="width: 300px;border-radius: 4%;"/>
                                </td>

                            </tr>

                            <tr id="2">
                                <td style="width: 100px">显示ID：</td>
                                <td style="width: 500px">
                                    <input type="text" th:value="${wl_homefloor_style_pc_bean.commodityids}" readonly="readonly" name="nameid"  class="form-control" style="width: 300px;border-radius: 4%;"/>
                                </td>
                                </tr>
                        </table>
                    </div>

                    <div>

                       </div>

                    <div id="upimage">
                    </div>
                    <button type="submit" id="formsubmit" class="btn btn-primary">保存信息</button>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- simditor -->
<script type="text/javascript" src="js/plugins/simditor/module.js"></script>
<script type="text/javascript" src="js/plugins/simditor/uploader.js"></script>
<script type="text/javascript" src="js/plugins/simditor/hotkeys.js"></script>
<script type="text/javascript" src="js/plugins/simditor/simditor.js"></script>
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = 'js/plugins/webuploader';
</script>
<script src="js/plugins/webuploader/webuploader.min.js"></script>

<script src="js/demo/webuploader-demo.js"></script>

<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>

<script src="js/jquery.min.js"></script>
<script>

    $(function () {

        $("#formsubmit").click(function () {
            //分类名称
            var flname = $("[name=flname]").val();
            //楼层顺序
            var lcsx = $("[name=lcsx]").val();
            //商品id
            var nameid = $("[name=nameid]").val();

            $.ajax({
                type: 'POST',
                url: 'wl_homefloor_style_pc_insert',
                data: {
                    flname: flname,
                    lcsx:lcsx,
                    nameid:nameid
                },
                dataType: 'json',
                success: function (data) {
                    //alert(data.valueOf())
                    if (data.valueOf()) {

                        if(data>0){
                            alert("新增成功");
                            window.location.href="wl_homefloor_style_pc_all";
                            return;
                        }else{
                            alert("新增失败");
                        }
                    } else {
                        alert('没有该商品');
                    }
                },
                error: function (err) {
                    alert('出错了');
                }
            });
        });

        $("#formsubmit").click(function () {
            //分类名称
            var flname = $("[name=flname]").val();
            //楼层顺序
            var lcsx = $("[name=lcsx]").val();
            //商品id
            var nameid = $("[name=nameid]").val();
            //对象id
            var beanid = $("[name=beanid]").val();
            $.ajax({
                type: 'post',
                url: 'wl_homefloor_style_pc_update',
                data: {
                    flname: flname,
                    lcsx:lcsx,
                    nameid:nameid,
                    beanid:beanid
                },
                dataType: 'json',
                success: function (data) {

                        if(data>0){
                            alert("修改成功");
                            location.href="wl_homefloor_style_pc_all";
                            return;
                        }else{
                            alert("修改失败");
                        }

                },
                error: function (err) {
                    alert('出错了');
                }
            });
        });
        
        
        //商品名称的模糊查询
        $(function () {
            $("#mhcx").click(function () {

                var mhname = $("#mhname").val();

                if(mhname==null ||  mhname==""){
                    return;
                }

                $.ajax({
                    type: 'POST',
                    url: 'wl_commodity_getbyname',
                    data: {
                        name: mhname
                    },
                    async: false,
                    dataType: 'json',
                    success: function (data) {
                        //alert(data.valueOf())
                            if (data.valueOf()) {
                                $("[name=axb] option").remove();
                                $.each(data, function(index, item){
                                    $("[name=axb]").append(' <option value="'+item.id+'">'+item.commodityname+'</option>');
                                });
                            } else {
                            alert('没有该商品');
                        }
                    },
                    error: function (err) {
                        alert('出错了');
                    }
                });
            });
        });

        //下拉框的改变事件(新增)
        $("[name=axb]").change(function () {

            var id = $(this).attr("id");


            var flname = $(this).val();

            var nameid = $("[name=nameid]").val();

            if(nameid!=""){
                $("[name=nameid]").val(nameid+","+flname);

            }else{
                $("[name=nameid]").val(flname);
            }

        });

        //下拉框的改变事件(删除)
        $("[name=axbs]").change(function () {

            var flname = $(this).val();

            var nameid = $("[name=nameid]").val();

            var array = nameid.split(",");

            var nameids = "";

            for (var i = 0;i<array.length;i++){

                if(array[i]==flname){
                    continue;
                }else{
                    if(nameids!=""){
                        nameids = nameids+","+array[i];
                    }else{
                        nameids = array[i];
                    }
                }
            }

            $("[name=nameid]").val(nameids);

        });

        //商品名称的模糊查询(删除)
        $(function () {
            $("#mhcxs").click(function () {

                var mhname = $("#mhnames").val();

                if(mhname==null ||  mhname==""){
                    return;
                }

                $.ajax({
                    type: 'POST',
                    url: 'wl_commodity_getbyname',
                    data: {
                        name: mhname
                    },
                    async: false,
                    dataType: 'json',
                    success: function (data) {
                        //alert(data.valueOf())
                        if (data.valueOf()) {
                            $("[name=axbs] option").remove();
                            $.each(data, function(index, item){
                                $("[name=axbs]").append(' <option value="'+item.id+'">'+item.commodityname+'</option>');
                            });
                        } else {
                            alert('没有该商品');
                        }
                    },
                    error: function (err) {
                        alert('出错了');
                    }
                });
            });
        });

        //新增

    });

</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<!--统计代码，可删除-->

</body>

</html>
